package com.wd.live.view.Activity

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import com.wd.live.R
import com.wd.live.base.BaseActivity
import com.wd.live.databinding.ActivityDengBinding
import com.wd.live.viewmodel.DengViewModel
import androidx.lifecycle.Observer
class DengActivity : BaseActivity<DengViewModel,ActivityDengBinding>(R.layout.activity_deng) {
    override fun dataObserver() {
        viewmodel.denglivedata.observe(this, Observer {
            if(it.status.equals("0000")){
                Toast.makeText(this, it.message, Toast.LENGTH_SHORT).show()



                startActivity(Intent(this,RefineActivity::class.java))
                finish()
            }else{
                Toast.makeText(this, it.message, Toast.LENGTH_SHORT).show()
            }
        })
    }

    override fun initViews() {
        binding.denglu.setOnClickListener {
            val sjh= binding.sjh.text.toString()
            val mima= binding.mima.text.toString()


            if(sjh.isEmpty()||mima.isEmpty()){
                Toast.makeText(this, "输入的账号或密码为空", Toast.LENGTH_SHORT).show()
            }

            viewmodel.dengluBoFang(mapOf("userName" to sjh,"passwd" to mima))
        }

    }

}